// pages/home/dec_budget/dec_budget.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    houseArea: 0,
    houseModelIndex: [0, 0, 0],
    totalPrice: 0,
    houseModelArray: [
      ['一室', '二室', '三室', '四室'],
      ['一厅', '二厅', '三厅'],
      ['一卫', '二卫', '三卫']
    ],
  },
  decBudgetDetailTap() {
    const { houseArea, houseModelIndex } = this.data
    if (houseArea < 10 || houseArea > 200) {
      wx.showToast({
        title: '请输入10-200房屋面积',
        icon: 'none'
      })
      return
    }
    wx.navigateTo({
      url: './detail/detail?houseArea=' + houseArea + '&houseModelIndex=' + houseModelIndex
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  // 输入房屋面积
  houseAreaInputBlur: function (res) {
    const houseArea = res.detail.value
    // 二室一厅一卫
    let houseModelIndex = this.data.houseModelIndex
    if (70 < houseArea && houseArea <= 100) {
      houseModelIndex = [1, 0, 0]
    }
    // 二室一厅二卫
    if (100 < houseArea && houseArea < 120) {
      houseModelIndex = [1, 0, 1]
    }
    // 二室一厅二卫
    if (120 < houseArea) {
      houseModelIndex = [2, 1, 1]
    }
    this.setData({
      houseArea: houseArea,
      houseModelIndex: houseModelIndex
    })
  },
  // 户型选择
  houseModelChange: function (res) {
    this.setData({
      houseModelIndex: res.detail.value
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})